//转运结算页面
<template>
  <div>
    <a-table
      :data-source="transferTableData"
      :pagination="false"
      class="checkTable"
    >
      <!-- 入库仓库 -->
      <a-table-column
        key="warehousingId"
        data-index="warehousingId"
        align="center"
        width="7%"
      >
        <span slot="title">入库仓库</span>
        <template slot-scope="text, record">
          <span>{{ record.warehouseName }}</span>
        </template>
      </a-table-column>
      <!-- 订单编号 -->
      <a-table-column
        key="transferNo"
        data-index="transferNo"
        align="center"
        width="8%"
      >
        <span slot="title">订单编号</span>
        <template slot-scope="text, record">
          <span>{{ record.transferNo }}</span>
        </template>
      </a-table-column>
      <!-- 客户编号 -->
      <a-table-column
        key="tenantId"
        data-index="tenantId"
        align="center"
        width="8%"
      >
        <span slot="title">客户编号</span>
        <template slot-scope="text, record">
          {{ record.tenantId }}
        </template>
      </a-table-column>

      <!-- 总箱数 -->
      <a-table-column
        key="boxSum"
        data-index="boxSum"
        align="center"
        width="8%"
      >
        <span slot="title">总箱数(箱)</span>
        <template slot-scope="text, record">
          {{ record.boxSum }}
        </template>
      </a-table-column>
      <!-- 币种 -->
      <a-table-column
        key="settlementCurrencyName"
        data-index="settlementCurrencyName"
        align="center"
        width="10%"
      >
        <span slot="title">币种</span>
        <template slot-scope="text, record">
          <span>{{ record.settlementCurrencyName }}</span>
        </template>
      </a-table-column>
      <!-- 费用 -->
      <a-table-column
        key="sumOfMoney"
        data-index="sumOfMoney"
        align="center"
        width="10%"
      >
        <span slot="title">费用</span>
        <template slot-scope="text, record">
          {{ record.sumOfMoney }}
        </template>
      </a-table-column>
      <!-- 状态 -->
      <a-table-column key="type" data-index="type" align="center" width="12%">
        <span slot="title">状态</span>
        <template slot-scope="text, record">
          {{ record.settlementState == "1" ? "已结算" : "待结算" }}
        </template>
      </a-table-column>

      <!-- 接收时间 -->
      <a-table-column
        key="sendBillTime"
        data-index="sendBillTime"
        align="center"
        width="12%"
      >
        <span slot="title">接收时间</span>
        <template slot-scope="text, record">
          <span>{{ record.sendBillTime }}</span>
        </template>
      </a-table-column>
      <!-- 结算时间 -->
      <a-table-column
        v-if="EndTime"
        key="settlementTime"
        data-index="settlementTime"
        align="center"
        width="12%"
      >
        <span slot="title">结算时间</span>
        <template slot-scope="text, record">
          <span>{{ record.settlementTime }}</span>
        </template>
      </a-table-column>
      <a-table-column
        key="action"
        data-index="action"
        align="center"
        width="12%"
      >
        <span slot="title">操作</span>
        <template slot-scope="text, record">
          <a
            href="javascript:;"
            style="text-decoration: underline; color: rgb(41, 41, 224)"
            @click="costServiceInfo(record)"
            >账单详情
          </a>
          <a-divider type="vertical" v-if="port != 2 && activeKey == '1'" />
          <a
            v-if="port != 2 && activeKey == '1'"
            href="javascript:;"
            style="text-decoration: underline; color: rgb(41, 41, 224)"
            @click="close(record)"
            >结算
          </a>
        </template>
      </a-table-column>
    </a-table>
    <!-- 服务项信息查看 -->
    <ServiceModalReap />
  </div>
</template>

<script>
import ServiceModalReap from "@/components/serviceModal/ServiceModalReap.vue";
import { transfer_sendBill } from "@/apis/system/FinanceManagement/FinanceManagement.js";
export default {
  props: [
    "getInList",
    "transferTableData",
    "EndTime",
    "searChTips",
    "activeKey",
  ],
  components: {
    ServiceModalReap,
  },
  data() {
    return {
      loading: false,
      rowData: {},
      port: sessionStorage.getItem("terminal"),
    };
  },
  methods: {
    //费用服务项信息查看
    costServiceInfo(record) {
      if (this.port == "1" && this.activeKey == "1") {
        setTimeout(() => {
          this.$bus.$emit(
            "reappearance",
            record,
            0,
            record.transferWarehousingApplyId,
            true
          );
        }, 50);
      } else if (this.port == "1" && this.activeKey == "2") {
        setTimeout(() => {
          this.$bus.$emit(
            "reappearance",
            record,
            0,
            record.transferWarehousingApplyId
          );
        }, 50);
      } else if (this.port == "1" && this.activeKey == "3") {
        setTimeout(() => {
          this.$bus.$emit(
            "reappearance",
            record,
            1,
            record.byTransferWarehousingOutApplyId
          );
        }, 50);
      }
      if (this.port != "1" && this.activeKey == "3") {
        setTimeout(() => {
          this.$bus.$emit(
            "reappearance",
            record,
            1,
            record.byTransferWarehousingOutApplyId
          );
        }, 50);
      } else if (this.port != "1" && this.activeKey != "3") {
        setTimeout(() => {
          this.$bus.$emit(
            "reappearance",
            record,
            0,
            record.transferWarehousingApplyId
          );
        }, 50);
      }
    },
    // 账单结算
    close(record) {
      let _this = this;
      this.$confirm({
        title: `确定要结算订单编号${record.transferNo}的数据吗?`,
        cancelText: "取消",
        okText: "确定",
        onOk() {
          return new Promise((resolve, reject) => {
            setTimeout(async () => {
              let { code } = await transfer_sendBill(
                record.transferWarehousingApplyId,
                1,
                record.revision
              );
              if (code === "10000") {
                _this.getInList(0);
                _this.searChTips();
                resolve();
              } else {
                reject();
              }
            }, 1000);
          }).catch(() => console.log("Oops errors!"));
        },
        onCancel() {},
      });
    },
  },
};
</script>
<style lang="less" scoped>
.action {
  a {
    border-bottom: 1px solid rgb(41, 41, 224);
    color: rgb(41, 41, 224);
  }
}
</style>
